import request from '@/utils/request'

// 查询信息列表
export function listMessage(query) {
  return request({
    url: '/message/message/list',
    method: 'get',
    params: query
  })
}

// 查询信息详细
export function getMessage(messageId) {
  return request({
    url: '/message/message/' + messageId,
    method: 'get'
  })
}

// 新增信息
export function addMessage(data) {
  return request({
    url: '/message/message',
    method: 'post',
    data: data
  })
}

// 修改信息
export function updateMessage(data) {
  return request({
    url: '/message/message',
    method: 'put',
    data: data
  })
}

// 删除信息
export function delMessage(messageId) {
  return request({
    url: '/message/message/' + messageId,
    method: 'delete'
  })
}

// 发送信息
export function sendMessage(data) {
  return request({
    url: '/message/sendMessage',
    method: 'post',
    data: data
  })
}

// 根据发送用户和接收用户获取聊天记录
export function findMessageBySendUserAndReceiveUser(sendUserId, receiveUserId) {
  return request({
    url: '/message/findMessageBySendUserAndReceiveUser',
    method: 'get',
    params: {
      sendUserId,
      receiveUserId
    }
  })
}

// 根据用户名查用户
export function searchUserByUserName(userName) {
  return request({
    url: '/user/searchUserByUserName',
    method: 'get',
    params: {
      userName
    }
  })
}
